package com.sy.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sy.dto.CourseUserPageQueryDTO;
import com.sy.mapper.CourseUserMapper;
import com.sy.mapper.CoursedetailMapper;
import com.sy.pojo.CourseUser;
import com.sy.pojo.Coursedetail;
import com.sy.result.PageResult;
import com.sy.service.CourseUserService;
import com.sy.service.CoursedetailService;
import com.sy.vo.CourseUserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class CourseUserServiceImpl
        extends ServiceImpl<CourseUserMapper, CourseUser> implements CourseUserService {

    @Autowired
    private CourseUserMapper courseUserMapper;

    /**
     * 报名课程分页查询
     * @param courseUserPageQueryDTO
     * @return
     */
    @Override
    public PageResult findAll(CourseUserPageQueryDTO courseUserPageQueryDTO) {
        Page<CourseUserVO> page = new Page<>(courseUserPageQueryDTO.getPage(),
                courseUserPageQueryDTO.getPageSize());
        page = courseUserMapper.findAll(page, courseUserPageQueryDTO.getName());
        return new PageResult(page.getTotal(), page.getRecords());
    }
}
